package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 攻略目录
 */
@Setter
@Getter
@JsonIgnoreProperties({"handler"})
public class StrategyCatalog extends BaseDomain {
    public static final boolean STATE_ON = true;    // 启用
    public static final boolean STATE_OFF = false;  // 禁用

    // 名称
    private String name;
    // 所属攻略
    private Strategy strategy;
    // 序号
    private Integer sequence;
    // 状态
    private boolean state;
    // 文章集合
    private List<StrategyDetail> details = new ArrayList<>();

    public String getJson() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", id);
        map.put("name", name);
        map.put("strategyId", strategy.getId());
        map.put("sequence", sequence);
        map.put("state", state);
        return JSON.toJSONString(map);
    }

    public String getStateName() {
        String stateName;
        if (state == STATE_ON) {
            stateName = "启用";
        } else {
            stateName = "禁用";
        }
        return stateName;
    }

}



